<template>
  <div class="share-content">
    <!-- 标签页 -->
    <el-tabs v-model="activeTab" @tab-click="handleTabClick">
      <el-tab-pane label="给我分享的" name="sharedWithMe" >
        <h3>给我分享的</h3>
        <el-table :data="sharedWithMeList" style="width: 100%">
          <el-table-column prop="title" label="文档名称" width="350">
            <template slot-scope="scope">
              <div class="table-item">
                <div class="table-title">
                  <p>{{ scope.row.title }}</p>
                  <span>{{ scope.row.fileType }} · {{ scope.row.size }}</span>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="from" label="分享对象" width="280">
            <template slot-scope="scope">
              <el-tag type="info">{{ scope.row.from }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="permission" label="权限" width="280">
            <template slot-scope="scope">
              <el-tag :type="scope.row.permission === '可编辑' ? 'primary' : 'info'">{{ scope.row.permission }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="time" label="分享时间" width="180"></el-table-column>
        </el-table>
        <el-pagination
          background
          layout="prev, pager, next"
          :total="totalItems"
          :page-size="pageSize"
          :current-page="currentPage"
          @current-change="handlePageChange"
        ></el-pagination>
      </el-tab-pane>

      <el-tab-pane label="我分享的" name="sharedByMe">
        <h3>我分享的</h3>
        <el-table :data="sharedByMeList" style="width: 100%">
          <el-table-column prop="title" label="文档名称" width="350">
            <template slot-scope="scope">
              <div class="table-item">
                <div class="table-title">
                  <p>{{ scope.row.title }}</p>
                  <span>{{ scope.row.fileType }} · {{ scope.row.size }}</span>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="to" label="分享对象" width="280">
            <template slot-scope="scope">
              <el-tag type="info">{{ scope.row.to }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="permission" label="权限" width="280">
            <template slot-scope="scope">
              <el-tag :type="scope.row.permission === '可编辑' ? 'primary' : 'info'">{{ scope.row.permission }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="time" label="分享时间" width="180"></el-table-column>
        </el-table>
        <el-pagination
          background
          layout="prev, pager, next"
          :total="totalItems"
          :page-size="pageSize"
          :current-page="currentPage"
          @current-change="handlePageChange"
        ></el-pagination>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeTab: 'sharedWithMe',
      sharedWithMeList: [
        {
          // icon: require('@/assets/doc-icon.png'),
          title: '项目进度报告',
          fileType: 'DOCX',
          size: '1.2MB',
          from: '李四',
          permission: '可编辑',
          time: '今天 09:15'
        },
        // 其他数据...
      ],
      sharedByMeList: [
        {
          // icon: require('@/assets/doc-icon.png'),
          title: '销售数据2023',
          fileType: 'XLSX',
          size: '3.5MB',
          to: '王五',
          permission: '可评论',
          time: '昨天 14:30'
        },
        // 其他数据...
      ],
      totalItems: 24,
      pageSize: 10,
      currentPage: 1
    };
  },
  methods: {
    handleTabClick(tab) {
      this.activeTab = tab.name;
    },
    handlePageChange(page) {
      this.currentPage = page;
      // 这里可以添加加载新数据的逻辑
    }
  }
};
</script>

<style scoped>
.table-item {
  display: flex;
  align-items: center;
}

.table-icon {
  width: 40px;
  height: 40px;
  margin-right: 10px;
}

.table-title p {
  font-size: 16px;
  margin: 0;
}

.table-title span {
  font-size: 12px;
  color: #999;
}
</style>
